//
//  BaseViewController.m
//  BlocksKitLearn
//
//  Created by Elvis on 2017/8/17.
//  Copyright © 2017年 Elvis. All rights reserved.
//

#import "BaseViewController.h"

#import <MBProgressHUD.h>
#import <UIView+Toast.h>



@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
}


#pragma mark - Private

- (void)showToastWithString:(NSString *)string TimeInterval:(NSTimeInterval)timeInterval Point:(CGPoint)point{
    [self.view makeToast:string duration:timeInterval position:[NSValue valueWithCGPoint:point]];
}

#pragma mark - Target Method

- (void)leftBarButtonItemAction{
    
}

- (void)rightBarButtonItemAction{
    
}


#pragma mark - Public

- (void)setNavagationBarTitle:(NSString *)title{
    self.navigationItem.title = title;
}

- (void)setLeftNavigationItemWithTitle:(NSString *)title{
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemAction)];
    self.navigationItem.leftBarButtonItem = leftItem;
}

- (void)setLeftNavigationItemWithImage:(UIImage *)image{
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonItemAction)];
    self.navigationItem.leftBarButtonItem = leftItem;
}

- (void)setRightNavigationItemWithTitle:(NSString *)title{
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonItemAction)];
    self.navigationItem.rightBarButtonItem = rightItem;
}

- (void)setRightNavigationItemWithImage:(UIImage *)image{
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonItemAction)];
    self.navigationItem.rightBarButtonItem = rightItem;
}

- (void)showHUDViewInView:(UIView *)shoView{
    [MBProgressHUD showHUDAddedTo:shoView animated:YES];
}

- (void)hideHUDViewForView:(UIView *)showView{
    [MBProgressHUD hideHUDForView:showView animated:YES];
}

- (void)toastWithString:(NSString *)string{
    [self showToastWithString:string TimeInterval:2 Point:self.view.center];
}

- (void)toastWithString:(NSString *)string Point:(CGPoint)point{
    [self showToastWithString:string TimeInterval:2 Point:point];
}

- (void)toastWithString:(NSString *)string Point:(CGPoint)point timeInterval:(NSTimeInterval)timerInterval{
    [self showToastWithString:string TimeInterval:timerInterval Point:point];
}

@end
